from bs4 import  BeautifulSoup
import requests
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.86"
}#此处使用headers将自己伪装成浏览器。
for start_num in range(0,250,25):
    response=requests.get(f"https://movie.douban.com/top250?start={start_num}", headers=headers)#确保爬虫到每一页的内容。
    html=response.text
    soup=BeautifulSoup(html,"html.parser")#因为BeautifulSoup除了能解析html，还能解析别的内容，所以要引入第二个参数,指定html解析器。
    all_titles=soup.findAll("span",attrs={"class":"title"})
    for title in all_titles:
        title_string=title.string
        if "/" not in title_string:
            print(title_string)
# print(soup.p)
# print(response.status_code)
# # print(response.text)
# all_prices=soup.find_all("p",atts={"class":"price_color"})
# for price in all_prices:
#     print(price.string)